#include <iostream>
#define SIZE 100
using namespace std;


void read();

int all[SIZE], lesss[SIZE], n, k, i, j;

int main()
{
	read();
	j = -1;

	for (i = 0; i <= n; ++i)
		if (all[i] % k == 0)
		{
			++j;
			lesss[j] = all[i];			
		}
	i = 0;
	while (i < j)
	{
		cout << lesss[i] << " ";
		++i;
	}
	return 0;
}

void read()
{
	
	cout << "n = ";
	cin >> n;
	cout << "k = ";
	cin >> k;
	for (i = 0; i < n; ++i)
	{	cout << "all[" << i << "]= ";
		cin >> all[i];
	}
}